import random

import requests


def random_code(length=6):
    return ''.join(random.choices('0123456789', k=length))


def send_message(tel, message):
    resp = requests.post(
        url="http://sms-api.luosimao.com/v1/send.json",
        auth=("api", "key-你自己申请的API-Key"),
        data={
            "mobile": tel,
            "message": message
        },
        timeout=3
    )
    return resp.json()


def main():
    code = random_code()
    message = f"您的短信验证码是：{code}，打死也不能告诉别人哟！【铁壳测试】"
    print(send_message('13548041193', message))


if __name__ == '__main__':
    main()
